﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using SuperSerialization;

namespace SuperSerialSamples.Timing
{
    class TimingSamples
    {
        public static TimingResult DeserializeNamespace()
        {
            StringReader reader = new StringReader("namespace SuperSerialSamples.Timing; List { Array : [ Empty { }, Empty { }, Empty { }, Empty { }, Empty { }, Empty { } ] }");

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            List obj = (List)Serializer.Deserialize(typeof(List), reader);

            stopwatch.Stop();
            return new TimingResult("Deserialization with namespace", stopwatch.Elapsed);
        }

        public static TimingResult DeserializeNoNamespace()
        {
            StringReader reader = new StringReader("SuperSerialSamples.Timing.List { Array : [ SuperSerialSamples.Timing.Empty { }, SuperSerialSamples.Timing.Empty { }, SuperSerialSamples.Timing.Empty { }, SuperSerialSamples.Timing.Empty { }, SuperSerialSamples.Timing.Empty { }, SuperSerialSamples.Timing.Empty { } ] }");

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            List obj = (List)Serializer.Deserialize(typeof(List), reader);

            stopwatch.Stop();
            return new TimingResult("Deserialization without namespace", stopwatch.Elapsed);
        }
    }

    class List
    {
        public Empty[] Array = {};
    }

    class Empty
    {

    }
}
